package com.example.tianyidemo.controller;

import com.example.tianyidemo.pojo.AddComment;
import com.example.tianyidemo.pojo.DeleteRequest;
import com.example.tianyidemo.pojo.Result;
import com.example.tianyidemo.service.AddcommentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@CrossOrigin//准许跨域请求
@RestController//包含@Controller（三层架构声明控制器）和@ResponseBody（转化json格式）
public class AddcommentController {
    @Autowired
private AddcommentService addcommentService;
    @PostMapping("/addcomment")
    public Result addcomment(@RequestBody AddComment request) {
        String CommentsContent = request.getCommentsContent();
        int CommentsUserID = request.getCommentsUserID();
        boolean isSuccess =addcommentService.addcomment(CommentsContent,CommentsUserID);
        if (isSuccess) {
            return Result.success("房源删除成功");
        } else {
            return Result.error("房源删除失败");
        }
    }



}
